var div;

function blah() {
  chrome.extension.sendRequest({type: "get"}, function(response) {
    alert(JSON.stringify(response));
  });
}

function updateDiv() {
  chrome.extension.sendRequest({type: "get"}, function(response) {
    div.innerHTML = response;
  });
}

function buildDiv() {
  div = document.createElement("div");
  div.id = "chromequotes";
  document.body.appendChild(div);
  // setInterval(blah, 100000);
  // blah();

  window.onscroll = function(e) {
    div.style.top = window.pageYOffset + "px";
  };
  
  updateDiv();
  setInterval(updateDiv, 15000);
}

function main() {
  // Ask whether user has content scripts turned on
  chrome.extension.sendRequest({type: "inject"}, function(response) {
    if (response) {
      buildDiv();
    }
  });
}

main();